layui.use(['form','layer'],function(){
    var form = layui.form
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery;

	    form.on("submit(addTest)",function(data){
	        console.log(data);	    
	        $.ajax({
	            type: "POST",
	            headers: {
	                token :  $.cookie('tokenA')
	            },
	            url: api+"exam/update",
	            data: {
	            	 id: $(".id").val(),
					 topicName:data.field.testName,					
					 topicScore:data.field.scoreTest,
					 aOptionContent:data.field.optionA,
					 bOptionContent:data.field.optionB,
					 cOptionContent:data.field.optionC,
					 dOptionContent:data.field.optionD,
					 correctOption:data.field.answer
	            },
	            success: function(result){
	            	
	            	console.log(result);
	            	if(result.code == 1){
	  		             top.layer.msg("试题修改成功！");
	//		             parent.location.reload();
	    		         setTimeout(function(){
				           parent.location.reload();
				       },1000);
	            	}
	            }
	        });
	        return false;
	    });
});

